#include <iostream>
using namespace std;

int max(int a, int b) {
	return a > b ? a : b;
}

int main() {
	int r;
	int d[1000][1001];
	cin >> r;
	for (int i = 0; i < r; i++)
		for (int j = 0; j < i; j++)
			cin >> d[i][j];
	for (int i = r - 2; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			d[i][j] = max(d[i][j] + d[i + 1][j], d[i][j] + d[i + 1][j + 1]);
		}
	}
	cout << d[0][0];

}
